<template>
  <div class="mask_view">
    <u-button class="btn" type="primary" v-if="!programState.browser.wx" @click="download">下载</u-button>
  </div>
  <maskInfo ref="overlay" />
</template>

<script setup>
import store from "@/store/store";
import { onLoad } from '@dcloudio/uni-app'
import { request } from "@/util/request";
import { ref, nextTick } from "vue";
import { baseUrl } from "@/config/config";
import maskInfo from '@/components/maskInfo/index.vue'
const { programState } = store
console.log(programState.browser)
const opt = ref()
const overlay = ref()

onLoad((option) => {
  opt.value = option
  if (programState.browser.wx) {
    console.log(overlay.value)
    nextTick(() => {
      overlay.value.open()
    })
  } else {
  }
})

function getUrl() {
  const typeUrl = {
    apply: baseUrl + `adminMobile/activityApplyExport/activityApplyList?act_id=${opt.value.id}&token=${opt.value.t}`,
    person: baseUrl + `admin/activityApplyExport/activityApplyUser?act_id=${opt.value.id}&token=${opt.value.t}`,
  }

  return typeUrl[opt.value.type]
}

function download() {
  window.open(getUrl())
}


</script>

<style lang="scss" scoped>
.mask_view {
  .btn {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20vh;
    width: 240px;
    height: 80px;
  }
}
</style>